<html>
<head><meta charset="utf-8"><title>cross compilation issue · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html">cross compilation issue</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212564964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212564964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212564964">(Oct 07 2020 at 14:19)</a>:</h4>
<p>Hi,<br>
I have successfuly cross compiled rustc on x86_86-unknown-linux-gnu system for arm-unknown-linux-gnu target. But I also need to cross compile it for the same target as the build one. The only difference is that the target uses sysrooted toolchain and possible other versions of system libraries. When using GNU autotools I use slighly different triplets for build system and for host/target system. For example x86_64-cross-linux-gnu and x86_64-pc-linux-gnu. But the Rust build system not recognize triplets other than x86_64-unknown-linux-gnu. How can I cross compile The Rust from one system to another (in the sysroot directory with possible different system libraries and symbols than in the build system) when build and target has the same architecture, i.e. x86_64-unknown-linux-gnu ?</p>



<a name="212565862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212565862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212565862">(Oct 07 2020 at 14:26)</a>:</h4>
<p>Rustc is always a cross-compiler. This means that you shouldn't built a different compiler that compiles for the host or target. You should use a single compiler. In your case you will likely want to set both <code>host</code> and <code>target</code> to <code>["x86_64-unknown-linux-gnu", "arm-unknown-linux-gnu"]</code> in <code>config.toml</code>. This will create two compilers (<code>host</code>) that each have a sysroot for both targets (<code>target</code>)</p>



<a name="212566522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212566522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212566522">(Oct 07 2020 at 14:31)</a>:</h4>
<p>There is no issues when cross compiling for arm target. The issue if cross compiling from x86_64 for another x86_64. If I build rust without cross compilation, then it will be linked with the libraries from build system. But I need that it will be linked with the libraries from the sysroot directory for another linux system. When buiding for the arm target, i have used arm-unknown-linux-gnu- prefixed toolchain for arm and native tools for the build system (stage 1 compiler). But how can I specify different tools when the build and target triplets are the same ? If I specify it in the target.x86_64-unknown-linux-gnu section of config.toml, then it will be used also for stage 1 compiler, but this is not correct.</p>



<a name="212567694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212567694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212567694">(Oct 07 2020 at 14:39)</a>:</h4>
<p>In other words I need to use different gcc  toolchains for the different stages and components. But how can I do this when both build and target have the same triplet ?</p>



<a name="212568402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212568402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212568402">(Oct 07 2020 at 14:44)</a>:</h4>
<p>It would be good if there be ability to specifying stage 1 build tools (cc, cxx, ar, ranlib) in the [build] section and the tools for the stage 2 and std lib in [target.&lt;triplet&gt;] section.</p>



<a name="212568541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212568541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212568541">(Oct 07 2020 at 14:45)</a>:</h4>
<p>Why do you need to use different gcc toolchains? Why not use the final toolchain for everything?</p>



<a name="212568893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212568893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212568893">(Oct 07 2020 at 14:47)</a>:</h4>
<p>Because then I use final toolchain for everything, the stage 1 compiler fails to run because it is linked with libraries from the target sysroot and not from the build system.</p>



<a name="212569141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212569141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212569141">(Oct 07 2020 at 14:49)</a>:</h4>
<p>What is the difference between the two toolchains? Why does only one work on the build system?</p>



<a name="212569288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212569288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212569288">(Oct 07 2020 at 14:50)</a>:</h4>
<p>The stage 1 rust compiler should be built with the native build toolchain, but for the final stage 2 the target toolchain should be used. Because stage 1 rust compiler needs to run on the build system and not on the target one.</p>



<a name="212569456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212569456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212569456">(Oct 07 2020 at 14:51)</a>:</h4>
<p>What is the target system?</p>



<a name="212569859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212569859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212569859">(Oct 07 2020 at 14:53)</a>:</h4>
<p>The target system is x86_64-unknown-linux-gnu. The same as the build one. But set and versions of system components may be different. The target cross gcc toolchain have been configured with "--with-sysroot" option.</p>



<a name="212570108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212570108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212570108">(Oct 07 2020 at 14:54)</a>:</h4>
<p>Can you compile everything for the host and then at when running the resulting rustc pass the target toolchain?</p>



<a name="212570114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212570114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212570114">(Oct 07 2020 at 14:54)</a>:</h4>
<p>In other word the target system should be isolated from the build one, despite thet it have the same architecture.</p>



<a name="212570390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212570390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212570390">(Oct 07 2020 at 14:57)</a>:</h4>
<p>I am thinking about two stage compilation that you suggest. But how exactly can I do this ?</p>



<a name="212570556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212570556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212570556">(Oct 07 2020 at 14:58)</a>:</h4>
<p>How should I use the "--stage" and "--keep-stage" options and what components should I build in the each stage of compilation ?</p>



<a name="212571189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212571189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212571189">(Oct 07 2020 at 15:01)</a>:</h4>
<p>The <code>[target.x86_64-unknown-linux-gnu]</code> section in <code>config.toml</code> allows you to specify the linker and C/C++ compiler.</p>



<a name="212571798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212571798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212571798">(Oct 07 2020 at 15:05)</a>:</h4>
<p>I do so, but in this case the stage 1 rust compiler also uses this linker and C/C++ compiler. And this is not correct since the stage 1 rust compiler should use the build system's linker and C/C++ compiler as It need to run on the build system for compiling the final stage 2 rust compiler with the linker and C/C++ compiler specified in the [target.x86_64-unknown-linux-gnu] section.</p>



<a name="212572847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212572847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212572847">(Oct 07 2020 at 15:10)</a>:</h4>
<p>I think that the Rust build system should always use native system's C/C++ compiler for the stage 1 rust compiler, or it should be possible to specify C/C++ compiler and linker for the stage 1 rust compiler in the [build] section of config.toml. Since the C/C++ compiler and linker specified in the [target.&lt;triplet&gt;] section should only be used for the final stuff that not intended to run on the build system, even if the target and the build system have tha same architecture and triplet.</p>



<a name="212575211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212575211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212575211">(Oct 07 2020 at 15:25)</a>:</h4>
<p>The same is for llvm-config option</p>



<a name="212579740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212579740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212579740">(Oct 07 2020 at 15:55)</a>:</h4>
<p>That configuration doesn't (to my knowledge) in any way go into the produced binaries, it's purely "how to build"</p>



<a name="212652168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212652168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212652168">(Oct 08 2020 at 06:46)</a>:</h4>
<blockquote>
<blockquote>
<p>Can you compile everything for the host and then at when running the resulting rustc pass the target toolchain?</p>
</blockquote>
</blockquote>
<p>I have tried to compile for the host with --stage 0 option, and then running the second pass with the target toolchain and the --keep-stage 0 option. But unfortunately x.py tries to recompile the bootstrap components and fails on this. How can I avoid this ?</p>



<a name="212652354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212652354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212652354">(Oct 08 2020 at 06:49)</a>:</h4>
<p>Why bootstrap is recompiled when config.toml is changed ? It make it impossible to use two pass compilation of different stages with the different toolchains.</p>



<a name="212652587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212652587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212652587">(Oct 08 2020 at 06:53)</a>:</h4>
<p>What is the correct way to cross compile the Rust in my case ? I.e. for the same architecture as the build system's, but with different system and llvm libraries isolated in sysroot dir ? The sysroot dir contains components capable to boot themselves.</p>



<a name="212715567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212715567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212715567">(Oct 08 2020 at 16:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="330140">Denis Onishchenko</span> <a href="#narrow/stream/122651-general/topic/cross.20compilation.20issue/near/212652354">said</a>:</p>
<blockquote>
<p>Why bootstrap is recompiled when config.toml is changed ? It make it impossible to use two pass compilation of different stages with the different toolchains.</p>
</blockquote>
<p>I would use different worktrees for this and set <code>rustc = ...</code> to the first one you compile</p>



<a name="212715584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212715584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212715584">(Oct 08 2020 at 16:27)</a>:</h4>
<p><a href="https://rustc-dev-guide.rust-lang.org/building/suggested.html?highlight=worktree#working-on-multiple-branches-at-the-same-time">https://rustc-dev-guide.rust-lang.org/building/suggested.html?highlight=worktree#working-on-multiple-branches-at-the-same-time</a></p>



<a name="212715646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212715646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212715646">(Oct 08 2020 at 16:27)</a>:</h4>
<p>this is how I did <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/.60x.2Epy.20check.60.20using.20stage.201.3F">https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.60x.2Epy.20check.60.20using.20stage.201.3F</a></p>



<a name="212715737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212715737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212715737">(Oct 08 2020 at 16:28)</a>:</h4>
<p><span class="user-mention silent" data-user-id="330140">Denis Onishchenko</span> <a href="#narrow/stream/122651-general/topic/cross.20compilation.20issue/near/212652354">said</a>:</p>
<blockquote>
<p>Why bootstrap is recompiled when config.toml is changed ? It make it impossible to use two pass compilation of different stages with the different toolchains.</p>
</blockquote>
<p>this is intentional, otherwise your config.toml won't match the compiler you've built which is <em>extremely</em> confusing</p>



<a name="212817471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212817471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212817471">(Oct 09 2020 at 12:22)</a>:</h4>
<p>This is still problematic, as when building the bootstrap component the target linker is used, and not the host's one. Because when the target's architecture is the same as the build architecture, there is only one section [target.x86_64-unknown-linux-gnu] where the C/C++ toolchain is specified. No matter which rustc is used. bootstrap is failed to build in this case. It should always use build system C/C++ toolchain and not a one specified in [target.x86_64-unknown-linux-gnu].</p>



<a name="212818309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212818309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212818309">(Oct 09 2020 at 12:30)</a>:</h4>
<p>it's not necessary to use two stage bootstrap for me. Building rustc/std/cargo with the target C/C++ toolchain and locally installed rust is sufficient. But even this is not working because bootstrap is building with the target C/C++ toolchain, that is wrong.</p>



<a name="212828942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212828942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212828942">(Oct 09 2020 at 13:58)</a>:</h4>
<p>I don't really understand why you have different toolchains / need different toolchains</p>



<a name="212847587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212847587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212847587">(Oct 09 2020 at 16:25)</a>:</h4>
<p>Because I need to build another linux system. First I build gcc cross toolchain configured with sysroot option. Then I build linux kernel, c library, initialization system, shell processor, other utils and rust compiler. The sys-root directory contains all files that belong to the built system. The C/C++ toolchain configured in such a way that it looks for headers and libraries in this sys-root directory. Then I will copy content of this sys-root directory on the new file system and boot the built system from this file system. l have no problem with building all components except the Rust due to described limitations of its build system.</p>



<a name="212848673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212848673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212848673">(Oct 09 2020 at 16:35)</a>:</h4>
<p>Cross compilation not always means building for the another architecture but also for another isolated system, even if this system use the same cpu architecture, kernel and C library. The versions may be different. This case is not supported by the Rust build system.</p>



<a name="212848784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212848784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212848784">(Oct 09 2020 at 16:36)</a>:</h4>
<p>I am unfamiliar, but why can you not just copy the built Rust files from system A to system B?</p>



<a name="212848859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212848859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212848859">(Oct 09 2020 at 16:37)</a>:</h4>
<p>the target config should only be used during the build, not anything further (i.e., the compiled artifacts don't contain it)</p>



<a name="212848862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212848862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212848862">(Oct 09 2020 at 16:37)</a>:</h4>
<p>because they are linked with the different libraries. For example the system where I build the Rust have LLVM 10 installed, but the target one have LLVM 11, and so on.</p>



<a name="212848903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212848903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212848903">(Oct 09 2020 at 16:37)</a>:</h4>
<p>hm okay</p>



<a name="212848998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212848998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212848998">(Oct 09 2020 at 16:38)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="138448">@cuviper</span> since maybe you do something similar when building rust for distro use</p>



<a name="212849006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212849006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212849006">(Oct 09 2020 at 16:38)</a>:</h4>
<p>but I suspect that yes this is just not supported</p>



<a name="212849061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212849061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212849061">(Oct 09 2020 at 16:39)</a>:</h4>
<p>our distro builds are all native</p>



<a name="212849187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212849187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212849187">(Oct 09 2020 at 16:40)</a>:</h4>
<p>at most, the kernel may not be an exact OS match, but the rest is done in an exact chroot for the target OS, running native code</p>



<a name="212849207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212849207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212849207">(Oct 09 2020 at 16:41)</a>:</h4>
<p>yeah I thought so</p>



<a name="212850505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212850505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212850505">(Oct 09 2020 at 16:54)</a>:</h4>
<p>I suggest to add support fot the "cc", "cxx", "ar", "ranlib", "linker" and "llvm-config" options to the [build] section of config.toml. This options will be used for building the bootstrap component since it always should run on the build system. The same for other components that intended for run only on build system.</p>



<a name="212850967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212850967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212850967">(Oct 09 2020 at 16:58)</a>:</h4>
<p>To avoid collisions when the build and target system's triplets are match.</p>



<a name="212851649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212851649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212851649">(Oct 09 2020 at 17:04)</a>:</h4>
<p>Can you add a custom target that just duplicates x86_64-unknown-linux-gnu and cross-compile for that?</p>



<a name="212851713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212851713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212851713">(Oct 09 2020 at 17:05)</a>:</h4>
<p>tbh I am still not quite clear why you need different C/C++ compilers vs different (e.g.) linker arguments</p>



<a name="212851733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212851733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212851733">(Oct 09 2020 at 17:05)</a>:</h4>
<p>How can I add a custom target ?</p>



<a name="212851852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212851852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212851852">(Oct 09 2020 at 17:06)</a>:</h4>
<p>well, actually</p>



<a name="212851854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212851854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212851854">(Oct 09 2020 at 17:06)</a>:</h4>
<p>I need different C/C++ compiler because it needs to look for the headers and libraries in the sys-root directory for the target system</p>



<a name="212851938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212851938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212851938">(Oct 09 2020 at 17:07)</a>:</h4>
<p>can't the build host use that compiler too?</p>



<a name="212852273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212852273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212852273">(Oct 09 2020 at 17:10)</a>:</h4>
<p>I think <span class="user-mention" data-user-id="330140">@Denis Onishchenko</span> is saying that no, because those libraries are not available on the build host perhaps?</p>



<a name="212852283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212852283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212852283">(Oct 09 2020 at 17:10)</a>:</h4>
<p>(though I am not clear on this point)</p>



<a name="212852333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212852333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212852333">(Oct 09 2020 at 17:11)</a>:</h4>
<p>it seems like if the target triple is the same though you should be able to compile everything inside a chroot or whatever with those libraries... unless I'm missing something</p>



<a name="212852594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212852594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212852594">(Oct 09 2020 at 17:13)</a>:</h4>
<p>Yes, the build host cann't use the compiler for the target, because the target may have the different versions of libraries</p>



<a name="212853073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212853073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212853073">(Oct 09 2020 at 17:18)</a>:</h4>
<p>yeah, I'd suggest using a chroot or container with the target toolchain/libraries/etc.</p>



<a name="212853556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212853556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212853556">(Oct 09 2020 at 17:23)</a>:</h4>
<p>chroot will work only for the same CPU architecture, but my distro build infrastructure supports different target architectures. In a particular case CPU architectures may match, but not always.</p>



<a name="212853682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212853682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212853682">(Oct 09 2020 at 17:24)</a>:</h4>
<p>I don't want use the different building infrastructure for different architectures. I want unified one.</p>



<a name="212853826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212853826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Denis Onishchenko <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212853826">(Oct 09 2020 at 17:25)</a>:</h4>
<p>otherwise it will be very ugly.</p>



<a name="212874527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/cross%20compilation%20issue/near/212874527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> o ninja <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/cross.20compilation.20issue.html#212874527">(Oct 09 2020 at 20:54)</a>:</h4>
<p>also causes a lot of errors in the compiler</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>